package online.hxstart.code.concurrent.chapter03;

import java.util.concurrent.TimeUnit;

/**
 * @author huxing
 * @date 19-4-23 星期二 下午3:46
 * @describe
 */
public class ThreadSleep {

  public static void main(String[] args) throws InterruptedException {
    //
    new Thread(
            () -> {
              try {
                long startTime = System.currentTimeMillis();
                TimeUnit.SECONDS.sleep(2);
                long endTime = System.currentTimeMillis();
                System.out.println(String.format("Total sprn %d ms", (endTime - startTime)));
              } catch (InterruptedException e) {
                e.printStackTrace();
              }
            })
        .start();
    long startTime = System.currentTimeMillis();
    TimeUnit.SECONDS.sleep(2);
    long endTime = System.currentTimeMillis();
    System.out.println(String.format("Main thread tatal sprnd %d ms", (endTime - startTime)));
  }
}
